package view.pieces;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.Rectangle2D;
import java.util.Observable;

import javax.swing.ImageIcon;

import resources.GlobalSettings;
import resources.ImageBundle;

import model.pieces.Box;

public class BoxDisplayView extends PieceDisplayView {

	private static final Image boxImage = new ImageIcon(ImageBundle.get("box_" + GlobalSettings.pieceImageWidth)).getImage();

	public BoxDisplayView(Graphics2D g2d, Box box) {
		super(g2d, box);
		this.oldPiece = new Box(box.getCol(), box.getRow());
	}

	@Override
	public void paint(Graphics2D g2D) {
		this.g2D = g2D;
		
		clearOldPiece();
		this.oldPiece = new Box(piece.getCol(), piece.getRow());
		
		Rectangle2D rect = getPieceRectangle();
		
		this.g2D.setColor(GlobalSettings.levelPanelColor);
		this.g2D.fill(rect);
		this.g2D.setColor(GlobalSettings.levelPanelColor);
		this.g2D.draw(rect);
		
		this.g2D.drawImage(boxImage,
				(int) rect.getMinX(), (int) rect.getMinY(), (int) rect.getMaxX(), (int) rect.getMaxY(),
				0, 0, GlobalSettings.pieceImageWidth, GlobalSettings.pieceImageHeight,
				null);
		/*
		//color caja
		Color Marron=new Color(164, 82, 0);//164,82,
		//color borde
		Color Marron1=new Color(79, 39, 0);//164,82,
		//color letra
		Color Letra=new Color(45, 22, 0);//164,82,
		//caja
		this.g2D.setColor(Marron);
		this.g2D.fill3DRect((int)rect.getX()+3,(int)rect.getY()+5, 34, 10,true);
		this.g2D.setColor(Marron1);
		this.g2D.draw3DRect((int)rect.getX()+3,(int)rect.getY()+5,34,10,true);
		//parte abaja
		this.g2D.setColor(Marron);
		this.g2D.fill3DRect((int)rect.getX()+5,(int)rect.getY()+15, 30, 23,true);
		this.g2D.setColor(Marron1);
		this.g2D.draw3DRect((int)rect.getX()+5,(int)rect.getY()+15,30,23,true);
		//texto
		//TextArea textArea= new TextArea("TextArea", (int)rect.getX()+15, (int)rect.getY()+15);
		this.g2D.setColor(Letra);
		this.g2D.drawString("CAJA",(int)rect.getX()+7,(int)rect.getY()+26);
		*/
	}

	@Override
	public void update(Observable o, Object arg) {
		this.paint(this.g2D);
	}

}